<?php
// +----------------------------------------------------------------------
// | HKCMS 异常处理
// +----------------------------------------------------------------------
// | Copyright (c) 2012-2019 http://www.hkcms.cn, All rights reserved.
// +----------------------------------------------------------------------
// | Author: 广州恒企教育科技有限公司 <admin@hkcms.cn>
// +----------------------------------------------------------------------
namespace common\exception;

use Exception;
use think\exception\Handle;
use think\exception\HttpException;

class Http extends Handle
{
    public function render(Exception $e)
    {
        // 请求异常 404
        if ($e instanceof HttpException) {
            if ($e->getMessage()=='module not exists:html') {
                return response('<p align="center">静态文件不存在，请在后台生成静态文件再尝试！<a href="http://bbs.hkcms.cn/thread-9.htm">论坛求助</a></p>', $e->getStatusCode());
            } else {
                if (APP_DEBUG==false) {
                    return response('<p align="center">'.$e->getMessage(), $e->getStatusCode());
                }
            }
        }

        return parent::render($e);
    }
}